#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
unsigned int blocksize[3] = {1024*1024,1024,1};
long long maximum = 0; //一定要用longlong，占8个字节，不然maximum会溢出
int main(int argc,char* argv[])
{
    unsigned int i,count;
     for(i = 0;i<3;i++)
     {
        // printf("ok");
        for (count = 1;;count++)
         {
             void* p;
              p = malloc(maximum+blocksize[i]*count);
            //   printf("%lld\r\n",maximum);
             if(p!=NULL)
             {
                 maximum = maximum + blocksize[i]*count;
                 free(p);
                 p = NULL;
             }
             else 
             {
                 
                 break;
             } 
         }
     }
    printf("maximun size = %lld bytes\r\n",maximum);
}
//test
